/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.mkyong.config;

import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.data.mongodb.core.MongoOperations;

/**
 *
 * @author dell
 */
public class MongoUtil {

    private static MongoOperations mongoOperations;

    private MongoUtil() {
    }

    public static MongoOperations getMongoOperations() {
        if (mongoOperations == null) {
            ApplicationContext ctx = new AnnotationConfigApplicationContext(SpringMongoConfig.class);
            mongoOperations = (MongoOperations) ctx.getBean("mongoTemplate");
        }
        return mongoOperations;
    }
}
